/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.modelo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Juan Pablo
 */
@Entity
@Table(name = "DEPARTAMENTO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DepartamentoP.findAll", query = "SELECT d FROM DepartamentoP d"),
    @NamedQuery(name = "DepartamentoP.findByIdDepartamento", query = "SELECT d FROM DepartamentoP d WHERE d.idDepartamento = :idDepartamento"),
    @NamedQuery(name = "DepartamentoP.findByNombre", query = "SELECT d FROM DepartamentoP d WHERE d.nombre = :nombre")})
public class DepartamentoP implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_DEPARTAMENTO")
    private BigDecimal idDepartamento;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "NOMBRE")
    private String nombre;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idDepartamento")
    private Collection<CiudadP> ciudadPCollection;

    public DepartamentoP() {
    }

    public DepartamentoP(BigDecimal idDepartamento) {
        this.idDepartamento = idDepartamento;
    }

    public DepartamentoP(BigDecimal idDepartamento, String nombre) {
        this.idDepartamento = idDepartamento;
        this.nombre = nombre;
    }

    public BigDecimal getIdDepartamento() {
        return idDepartamento;
    }

    public void setIdDepartamento(BigDecimal idDepartamento) {
        this.idDepartamento = idDepartamento;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    @XmlTransient
    public Collection<CiudadP> getCiudadPCollection() {
        return ciudadPCollection;
    }

    public void setCiudadPCollection(Collection<CiudadP> ciudadPCollection) {
        this.ciudadPCollection = ciudadPCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDepartamento != null ? idDepartamento.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DepartamentoP)) {
            return false;
        }
        DepartamentoP other = (DepartamentoP) object;
        if ((this.idDepartamento == null && other.idDepartamento != null) || (this.idDepartamento != null && !this.idDepartamento.equals(other.idDepartamento))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.modelo.DepartamentoP[ idDepartamento=" + idDepartamento + " ]";
    }
    
}
